#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    for(int test=0;test<T;test++)
    {
        int n,m,L,V;
        cin>>n>>m>>L>>V;
        int d[n],v[n],a[n],p[m],op[m]{0};
        for(int i=0;i<n;i++) cin>>d[i]>>v[i]>>a[i];
        for(int j=0;j<m;j++){cin>>p[j];}
        int out=0;
        for(int car=0;car<n;car++)
        {
            float mov=0,s=d[car],nv;
            int speed=v[car],quick=0;
            for(int t=1;speed>0&&s<L;t++)
            {
                mov+=speed*t+0.5*a[car]*t*t;
                s+=mov;
                nv=sqrt(speed*speed+2*a[car]*mov);
                int q;
                for(int j=0;j<m;j++)
                {
                    if(s>=p[j]&&nv>V){quick=1;q=j;}
                }
                speed=speed+a[car]*t;
                nv=sqrt(speed*speed+2*a[car]*mov);
                op[q]=nv<=V&&quick==1?1:(nv>V&&quick==1?1:0);
            }
            if(quick==1) out++;
        }
        int ans=0;
        for(int cs:op) ans+=cs==0?1:0;
        cout<<out<<' '<<ans<<endl;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
